package com.btkjgc.sms;

import com.btkjgc.utils.Constant;

import java.io.UnsupportedEncodingException;

/**
 * 短信网关，用于发送短信
 */
public class MessageGateway
{
	Client client;

	public MessageGateway()
	{
		try
		{
			client = new Client(Constant.SN, Constant.PWD);
		}
		catch (UnsupportedEncodingException e)
		{
			e.printStackTrace();
		}
	}

	/**
	 * 
	 * @param phoneNumber
	 *            发送的手机号
	 * @param msg
	 *            发送的消息内容
	 * @return 发送成功与否
	 */
	public boolean sendMessage(String phoneNumber, String msg)
	{
		msg += "【ROBOY】";
		String result = client.mt(phoneNumber, msg, "", "", "");
		System.out.println("result:" + result);
		if (result.startsWith("-") || result.equals(""))
		{
			return false;
		}
		else
		{
			return true;
		}
	}

}
